Skip to content

Conversation

egorzhdan
Copy link
Contributor

This adds an initial Clang modulemap for the WinRT module. The modulemap is injected into the winrt/ include search path using VFS.

For now, the modulemap only exposes a small number of utility headers from WinRT. It will be extended in the future to cover more of the WinRT API surface.

@egorzhdan
Copy link
Contributor Author

swiftlang/swift-installer-scripts#465

@swift-ci please smoke test

@egorzhdan
Copy link
Contributor Author

swiftlang/swift-installer-scripts#465

@swift-ci please build toolchain Windows

This adds an initial Clang modulemap for the WinRT module. The modulemap is injected into the `winrt/` include search path using VFS.

For now, the modulemap only exposes a small number of utility headers from WinRT. It will be extended in the future to cover more of the WinRT API surface.
@egorzhdan
Copy link
Contributor Author

swiftlang/swift-installer-scripts#465

@swift-ci please smoke test

@egorzhdan
Copy link
Contributor Author

swiftlang/swift-installer-scripts#465

@swift-ci please build toolchain Windows

@egorzhdan egorzhdan added the Windows Platform: Windows label Oct 3, 2025
Copy link
Member

@compnerd compnerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do a smoke test on the windows toolchain before merging

@egorzhdan
Copy link
Contributor Author

swiftlang/swift-installer-scripts#465

@swift-ci please build toolchain Windows ARM64

@egorzhdan
Copy link
Contributor Author

swiftlang/swift-installer-scripts#465

@swift-ci please smoke test Linux

@egorzhdan
Copy link
Contributor Author

swiftlang/swift-installer-scripts#465

@swift-ci please smoke test macOS

@egorzhdan
Copy link
Contributor Author

swiftlang/swift-installer-scripts#465

@swift-ci please build toolchain Windows ARM64

@compnerd
Copy link
Member

compnerd commented Oct 6, 2025

swiftlang/swift-installer-scripts#465

@swift-ci please build toolchain Windows

@stevenbrix
Copy link

It will be extended in the future to cover more of the WinRT API surface.

how far does this plan on going? will it eventually include all Windows.* headers in the WinRT folder?

ucrt.modulemap
winsdk_um.modulemap
winsdk_shared.modulemap
WinRT.modulemap

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

winsdk_winrt seems like a more consistent name? it would be ideal to import WinSDK.WinRT as opposed to import WinRT. the latter can cause lots of collisions with other WINMD based projection tools which will generate code in the WinRT module

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is WinRT considered part of the Win32 SDK? I thought it was a separate parallel piece. The submodule support isn't sufficient to support that in Swift I think? So this will need to be a top-level module.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is just the "Windows SDK" . the distinction between Win32 and WinRT are the APIs used. but since the module is called WinSDK it seems appropriate to keep them all together? if WinSDK was named Win32 i would feel differently

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are other submodules in WinSDK, so that should be fine?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WinRT can't be a submodule of WinSDK mostly for build performance reasons. WinRT headers are huge, for instance for WinUI headers alone Clang produces a .pcm that is 300MB+ and takes over 10 minutes to precompile on my machine (with weak specs). Clang builds .pcms per top-level module, so all submodules are effectively merged into one. Similarly, Swift merges all submodules into a single module when importing them. That means that for a project that only uses Win32, clang would spend significant time prebuilding WinRT headers, and then Swift would spend time importing WinRT decls into Swift.

For this reason, I'm going to propose splitting WinRT headers into many top-level modules, e.g. having a top-level module WindowsXyz per windows.xyz.*.h. But that is out of scope of this PR ;)

the latter can cause lots of collisions with other WINMD based projection tools which will generate code in the WinRT module

Is WinRT a conventional name for some of the modules that are generated by other tools?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this reason, I'm going to propose splitting WinRT headers into many top-level modules, e.g. having a top-level module WindowsXyz per windows.xyz.*.h. But that is out of scope of this PR ;)

Does the fact that namespaces in WinRT can have cyclical dependencies affect this at all?

@egorzhdan
Copy link
Contributor Author

how far does this plan on going? will it eventually include all Windows.* headers in the WinRT folder?

I think that would be the ideal outcome, yes! However I don't yet have a concrete plan to list every single WinRT header in the modulemap, and I'm not sure if Swift will actually be able to correctly digest all of them. For now I'm mostly interested in WinUI and its dependencies.

@stevenbrix
Copy link

For now I'm mostly interested in WinUI and its dependencies.

The most interesting WinRT development is done in WindowsAppSDK (with UWP you're limited to the sandbox, which may be ok, but for most it isn't) and those don't ship in the Windows SDK.

@stevenbrix
Copy link

I'm curious, why does swift want to go down this route of including windows.* headers from the SDK, as opposed to using a winmd based code generator tool? those headers in the windows SDK aren't really meant for consumption.

unless you have plans for neat tricks, writing Swift from those headers would feel very much like writing WRL in C++

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Windows Platform: Windows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants